#!/bin/sh
#
# 简单写一下脚本的功能。
#
#
#

if [ $# -ne 1 ]; then
	echo "Usage: $0 mdfile"
	exit
fi

awk -F '[《》]' '{

	if (NF>1) {
		for (counter = 2; counter < NF+1; counter =counter+2) {

			print "《" $counter "》"
		}
	} 
}'  $1 >index_books.md

sort index_books.md |uniq  |awk '{print "["$1"](https://www.baidu.com/s?ie=UTF-8&wd="$1")\n"}' >tmp.md

mv tmp.md index_books.md

echo '本书中所提到的书籍： ' index_books.md

